// 自定义指令的注册
import Vue from 'vue'
import router from '@/router'

Vue.directive('permission', {
  //自定义事件 
  inserted(el, binding) {
    console.log(el)
    console.log(binding)
    const action = binding.value.action
    const effect = binding.value.effect
    //如果不具备这个权限 就删除掉
    console.log(router);
    if (router.currentRoute.meta.indexOf(action) === -1) {
      if (effect === 'disabled') {
        el.disabled = true
        el.classList.add('is-disabled')
      } else {
        el.parentNode.removeChild(el)
      }
    }
  }
})

